#include "GameController.h"


GameController::GameController(View* view)
{
	this->gameModel = new GameModel();
	this->setView(new GameView(view, this->gameModel));
	
	this->buttonAnimation = new GameButtonController(SDLK_s, SDLK_p);
	this->buttonAnimation->setView(this->getView());

	this->getView()->loadMedia();
}

bool GameController::loadView(){
	return this->getView()->loadMedia();
}

bool GameController::getFlagContinue() {
	return this->buttonAnimation->getFlagContinue();
}

void GameController::setFlagContinue(bool flagContinue) {
	this->buttonAnimation->setFlagContinue(flagContinue);
}


void GameController::updateView(){
	this->getView()->update();
}

void GameController::updateModel(){
	this->getGameModel()->step();
}

GameModel* GameController::getGameModel() {
	return this->gameModel;
}

void GameController::setGameModel(GameModel* gameModel) {
	this->gameModel = gameModel;
}

Controller* GameController::handleEvent(SDL_Event* event) {
	return this->buttonAnimation->handleEvent(event);
}


GameController::~GameController()
{
	delete this->buttonAnimation;
	delete this->getView();
	delete this->gameModel;
}
